"use strict";

const path = require("node:path");
const webpack = require("webpack");

/**
 * @type {import("webpack").Configuration}
 */
module.exports = {
  entry: {
    // 统一打包的类库
    vendor: ["angular", "angular-loader"],
  },
  output: {
    path: path.join(__dirname, "dist"),
    filename: "[name].dll.js",
    // library: "[name]-[hash]",
  },
  plugins: [
    new webpack.DllPlugin({
      // name 必须和 output.library 一致
      name: "[name]-[hash]",
      // 该属性需要与 DllReferencePlugin 中一致
      context: __dirname,
      path: path.join(__dirname, "dist", "[name]-manifest.json"),
    }),
    new webpack.optimize.AggressiveSplittingPlugin({
      minSize: 30000,
      maxSize: 50000,
    }),
  ],
  recordsInputPath: path.join(__dirname, "records.json"),
  recordsOutputPath: path.join(__dirname, "newRecords.json"),
};
